<?php
require_once BACKGROUND_COMMON_ACTION_SERVICE_DIR . '/default.php';

class background_good_index_action_service extends background_default_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {                	                 
        $page_num = init_user_data_key($_GET, 'page_num', 'int');
        $item_count = 20;
        $page_range = 5;      
        
        $where = array();
        //编号
        $id = init_user_data_key($_GET, 'id', 'int');
        if($id > 0){
            self::add_view_data('id', $id);
            $where['id'] = $id;
        }else{
            self::add_view_data('id', '');
        }
        //关键词
        $keywords = init_user_data_key($_GET, 'keywords', 'str', '');
        self::add_view_data('keywords', $keywords);
        if($keywords !== ''){
            $where['name'] = $keywords;
        }        
        
        $model_background_good = wwy_resource_container::get_model_background_good();

        $order = array('`order` asc', 'id desc');
        $options = array('page_num' => $page_num, 'item_count' => $item_count, 'page_range' => $page_range);
        $list = $model_background_good->get_list($where, $order, $options);
        
        self::add_view_data('good_list', $list['list']);
        self::add_view_data('page_data', $list['page_data']);
    }
}